import { isNoNullOrUndefind } from "@/utils/utils";
import VueRouter from "vue-router";
import r1 from "./routes/r1";
import r2 from "./routes/r2";
import store from "@/store";
const routes = r1.concat(r2)
// console.log(routes)
const router = new VueRouter({
    routes,
    mode: 'history',
})
// console.log(router.getRoutes().length)
//前置路由守卫
router.beforeEach((to,from,next)=>{
    try {
       const mark= to.meta.pagemark
        store.commit('routes/setPagemark',mark)
    } catch (error) {
        store.commit('routes/setPagemark',null)
    }
    if(isNoNullOrUndefind(to.meta.title)) document.title=to.meta.title
    next()
})

export default router
